;*****************************************************
; 	Copyright (C) SEIKO EPSON CORP. 1997-2001
;	All rights Reserved
;
;	File name : memcpy.s
;	Function  :
;	       This is memcpy function
;	Revision  :
;		1997/03/14	M.Kudo start
;		1997/03/24	V.Chan changed to delayed jump
;		1997/03/31	V.Chan changed back to original
;		2001/12/06	T.Tazaki for GNU33(Linux)
;*****************************************************

;*****************************************************
; memcpy
;	memory copy from src to dest, N bytes
;
; arguments : %r6:dest addr, %r7:src addr, %r8 byte number
; return    : %r4:dest addr
;*****************************************************

	.section .text
	.align 1
	.global memcpy
	.type	 memcpy,@function
	
memcpy:
	ld.w 	%r4, %r6		; return dest addr

memcpy_loop:
	cmp		%r8, 0
	jreq	memcpy_ret
	ld.ub	%r10, [%r7]+	; copy src 1 byte to dest
	ld.b	[%r6]+, %r10
	sub		%r8, 1		; decrement counter
	jp		memcpy_loop

memcpy_ret:
	ret
